<!DOCTYPE html>
<html>
<head><link rel="stylesheet" href="index.css"/></head>
<body>
<h1>Parser</h1>
<script type="module">
import Parser from '/js/parser.mjs';

let open = 0, close = 0;
const Grammar = {
  'Start': {
     rule: [ /</, ['Start', Parser.Terminal], />/ ],
     callback: (state, termIndex, match) => {
       if (termIndex == 0)
         open++;
       if (termIndex == 2)
         close++;
     }
  }
};


const text = '<<<<<>>>>>';
const offset = new Parser().parse(text, Grammar, 'Start');
console.log(offset == text.length ? 'match' : 'no match');
console.log(`open: ${open}, close: ${close}`);
</script>
</body>
</html>
